import { createVuePlugin } from 'vite-plugin-vue2'
import ViteCommonjs from 'vite-plugin-commonjs';
import viewHtmlPlugin from './scripts/vite-plugins/view.js';
import mockPlugin from './scripts/vite-plugins/proxy.js';
import path from 'path';

/** @type {import('vite').UserConfig} */
export default {
    define: {
        process: {
            env: {
                MY_BUILD_MODE: "production"
            }
        }
    },
    root: './',
    server: {
        host: 'hut.com',
        fs: {
            allow: ['..']
        },
        port: "5001",
        proxy:{
            '/libs/mock': {
                target: 'http://localhost:5001',
                changeOrigin: true,
                rewrite: (path) => path.replace(/\/libs\/mock/, '/helloris-front/src/libs/mock')
            },
        }
    },
    plugins: [
        ViteCommonjs(),
        createVuePlugin(),
        viewHtmlPlugin,
        mockPlugin,
    ],
    resolve: {
        extensions: ['.vue', '.js'],
        alias: {
            '@utils': './helloris-front/src/base/utils',
            '@jarvisBase': './helloris-front/src/views/jarvis/base',
            '~@workbench': path.resolve(__dirname,'./helloris-front/src/base/static/images/workbench'),
            '@workbench': path.resolve(__dirname,'./helloris-front/src/base/static/images/workbench'),
        },
    },
}